import com.sun.xml.internal.ws.addressing.WsaActionUtil;

import java.util.Arrays;

public class Test1 {
    public static void main(String[] args) {

        String str = " abcde fg hijk ";
        System.out.println(str);
        System.out.println(str.trim());

        /*String str = "192.168.1.1";
        String[] ret = str.split("\\.");
        for (int i = 0; i < ret.length; i++) {
            System.out.println(ret[i]);
        }*/

    }

    public static void main9(String[] args) {

        String str = "abcd abcd abcd";
        String ret1 = str.replaceAll("ab", "OO");
        System.out.println(ret1);

    }

    public static void main8(String[] args) {

        String str1 = "ababcababcd";
        int index1 = str1.lastIndexOf("abc");
        int index2 = str1.lastIndexOf("abc", 5); //从5位置倒着往回找
        int index3 = str1.lastIndexOf('c');
        int index4 = str1.lastIndexOf('c', 5);   //从5位置倒着往回找
        System.out.println(index1);
        System.out.println(index2);
        System.out.println(index3);
        System.out.println(index4);

    }

    public static void main7(String[] args) {
        String str = "abaababa";
        String ret = str.substring(1, 6);
        System.out.println(ret);
        System.out.println("---------------");
        String str2 = " sfhjsdlj slfjse   ";
        System.out.println(str2);
        System.out.println(str2.trim());
    }

    public static void main6(String[] args) {
        String str = "name=zhangsan&age=15";
        String[] ret = str.split("=|&");
        System.out.println(Arrays.toString(ret));
    }

    public static void main5(String[] args) {
        /*String str = "192.168.1.1";
        String[] ret = str.split("\\.");
        System.out.println(Arrays.toString(ret));*/

        String str = "192\\168\\1\\1";
        String[] ret = str.split("\\\\");
        System.out.println(Arrays.toString(ret));
    }

    public static void main4(String[] args) {
        String str = "hello abc world";
        String[] ret = str.split(" ", 2);
        System.out.println(Arrays.toString(ret));
    }

    public static void main3(String[] args) {
        String str = "abababcabcdababde";
        String ret = str.replace("ab", "123");
        String ret2 = str.replace('a', '9');
        String ret3 = str.replaceFirst("ab", "pppp");
        String ret4 = str.replaceAll("ab", "123");

        System.out.println(ret4);
        System.out.println(ret3);
        System.out.println(ret2);
        System.out.println(ret);
    }

    public static void main2(String[] args) {
        String s1 = "hello";
        char[] array = s1.toCharArray();
        for (char c : array) {
            System.out.println(c);
        }

        char[] array2 = {'a', 'b', 'c'};
        String str2 = new String(array2);
        System.out.println(str2);

        String s = String.format("%d-%02d-%02d", 2023, 8, 17);
        System.out.println(s);
    }

    public static void main1(String[] args) {

        /*String s1 = "hello";
        String s2 = s1.toUpperCase();
        System.out.println(s2);

        String s3 = "HELlo";
        String s4 = s3.toLowerCase();
        System.out.println(s4);*/

        /*int data = Integer.parseInt("123");
        System.out.println(data);*/
        /*int a = 12345;
        String s1 = String.valueOf(a);
        String s2 = String.valueOf(12.23232);
        System.out.println(s2);
        System.out.println(s1);*/
    }
}
